﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AugustSql
{
    public class Conver
    {
        public static string ConvertToString<T>(IEnumerable<T> _contents, string _separator)
        {
            return string.Join(_separator, _contents);

            //string a = "";
            //for (int i = 0; i < _contents.Count() - 1; i++)
            //{
            //    a += _contents.ToArray()[i] + _separator;
            //}
            //a += _contents.ToArray()[_contents.Count() - 1];
            //return a;
        }

        public static string ConvertToString<T>(IEnumerable<T>[] _contents, string _separatorRow, string _separatorCell)
        {
            string str = "";
            foreach (IEnumerable<T> a in _contents)
            {
                str = str + string.Join(_separatorCell, a) + _separatorRow;
            }
            return str;
        }



        public static string[][] ConvertDtToStringArry(DataTable _dt, string _separatorRow, string _separatorCell)
        {
            int count = _dt.Rows.Count;
            string[][] strArry = new string[count][];
            for (int i = 0; i < count; i++)
            {
                strArry[i] = Array.ConvertAll(_dt.Rows[i].ItemArray, Convert.ToString);
            }
            return strArry;
        }

        public static string[][] TransPosition<T>(T[][] _arry2)
        {
            string[][] arry = new string[_arry2[0].Count()][];
            for (int k = 0; k < _arry2[0].Count(); k++)
            {
                arry[k] = new string[_arry2.Count()];
            }

            for (int i = 0; i < _arry2.Count(); i++)
            {
                for (int j = 0; j < _arry2[i].Count(); j++)
                {
                    arry[j][i] = _arry2[i][j].ToString();
                }
            }
            return arry;
        }
    }
}
